<?php
declare (strict_types = 1);

namespace app\admin\controller;
use think\facade\View;
use think\facade\Db;
class Reward extends \app\admin\controller\Base
{
  
  public function _filter()
  {
    $query = [];
    $source = input('source');
    if ($source) {
      $query[] = ['source','=',$source];
    }

    $order_sn = input('order_sn');
    if ($order_sn) {
      $query[] = ['order_sn','=',$order_sn];
    }

    return $query;
  }

  public function ckvo($vo ='')
  {
    $user = Db::name('user')->where('id',$vo['uid'])->find();
    if (!$user) {
      $user['head'] = '';
      $user['nick'] = '';
      $user['pid'] = 0;
    }
    $vo['user'] = $user;
    $formula = $vo['total_fee'].' x '.$vo['ratio'];
    $vo['formula'] = $formula;

    $order = Db::name('order')
            ->field('goods_name,goods_img')
            ->where('order_sn',$vo['order_sn'])->find();
    if (!$order) {
      $order['pay_price'] = '';
      $order['goods_name'] = '';
      $order['goods_img'] = '';
    }
    $vo['order'] = $order;

    return $vo;
  }
}
